package stark.app.function.novelreader;

import android.os.Environment;

import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.SizeUtils;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;

import org.jetbrains.annotations.NotNull;

import java.io.File;

import stark.app.R;
import stark.app.databinding.ItemLocalNovelBinding;
import stark.common.basic.adapter.BaseDBRVAdapter;

/**
 * Author：daizhongbin on 2021/6/9
 * Email：1027154338@qq.com
 * Desc:
 */
public class LocalNovelAdapter extends BaseDBRVAdapter<File, ItemLocalNovelBinding> {

    public LocalNovelAdapter() {
        super(R.layout.item_local_novel, 0);
    }

    @Override
    protected void convert(@NotNull BaseDataBindingHolder<ItemLocalNovelBinding> holder, File file) {
        ItemLocalNovelBinding binding = holder.getDataBinding();
        binding.tvName.setText(file.getName());
        binding.tvSize.setText(ConvertUtils.byte2FitMemorySize(file.length()));
        binding.tvLocation.setText(file.getAbsolutePath().replace(Environment.getExternalStorageDirectory().getAbsolutePath(),
                "存储空间"));
    }
}
